$(function(){
	//下拉列表操作
	$("#deliveryMan").multipleSelect({
	    filter: true
	});
});


//add map area panelId 
var dopBtnorderqueryAdd = "";
var mapManager = null;
var isModify = false;

$("#dop_datagrid_orderquery").datagrid({
	url : "",
	height : 400,
	pagination : true,
	fitColumns : false,
	singleSelect : false,
	fit : true,
	pageSize : 10,
	pageList : [ 10, 30, 50, 100 ],
	sortOrder : 'desc',
	rownumbers : true,
	showFooter : true,
	frozenColumns : [ [] ],
	columns : [ [ {
		field : "id",
		width : 150,
		title : "主键",
		hidden : true
	}, {
		field : "sendPersonName",
		width : 150,
		title : "配送人"
	}, {
		field : "billNo",
		width : 150,
		title : "单号"
	}, {
		field : "number",
		width : 150,
		title : "数量"
	}, {
		field : "money",
		width : 80,
		title : "应交金额"
	}, {
		field : "salary",
		width : 150,
		title : "配送费提成"
	}, {
		field : "status",
		width : 150,
		title : "归班单状态"
	}, {
		field : "createTimeStr",
		width : 150,
		title : "归班日期"
	} ] ]
});
// click pagination
var p = $("#dop_datagrid_orderquery").datagrid('getPager');
$(p).pagination(
		{
			onSelectPage : function(pageNumber, pageSize) {
				var params = $.extend({
					pageNum : pageNumber,
					pageSize : pageSize
				}, getQueryParams());
				EapTools.doAction("returnCountController.do?query", params,
						false, function(data) {
							$("#dop_datagrid_orderquery").datagrid('loadData',
									{
										"rows" : data.list,
										"total" : data.count,
										"footer" : data.footer
									} || {});
						});
			}
		});

// bind query event
$("#dop_btn_orderquery_query").click(function() {
	init();
});

// get params
function getQueryParams() {
	return {
		deliveryMan : JSON.stringify($("select[code='deliveryMan']").val()),
		startdeliveryTime : $("input[code='startdeliveryTime']").val(),
		enddeliveryTime : $("input[code='enddeliveryTime']").val()
	// custAddress : $("select[code='custAddress']").val(),
	// payMethod : $("select[code='payMethod']").val()||0
	};
}

// init
function init() {
	// init
	var options = $("#dop_datagrid_orderquery").datagrid('getPager').data(
			"pagination").options;
	if($("input[code='startdeliveryTime']").val()>$("input[code='enddeliveryTime']").val()){
		jQuery.messager.alert('提示:','配送日期不能大于结束日期!');  
	}
	var pageSize = options.pageSize;
	var params = $.extend({
		pageNum : 1,
		pageSize : pageSize
	}, getQueryParams());
	debugger;
	EapTools.doAction("returnCountController.do?query", params, false,
	function(data) {
		$("#dop_datagrid_orderquery").datagrid('loadData', {
			"rows" : data.list,
			"total" : data.count,
			"footer" : data.footer
		} || {});
	});
	var p = $("#dop_datagrid_orderquery").datagrid('getPager');
	$("td:last", p).find("a").click();
}
